#ifndef CENEMY_H
#define CENEMY_H

#include "CEntity.h"
#include "CWeapon.h"
#include "CSpecialItem.h"
#include <list>
using namespace std;

class CWave;
class CEnemy;

class CAction
{
public:
	CAction( CEnemy* owner );
	~CAction();

	void PerformAction( float& action, float change, float time );
	bool UpdateAction();		//returns false if action wasn't updated, meaning it's finished

	CEnemy*	 Owner;				//the enemy that will be influenced by this action
	float*	 Action;			//reference to an action that can be changed. faceangle, speed, size, life, damage etc...
	float	 ActionChange;		//the change to be performed to the action during ActionTime
	float	 ActionTime;	    //total time for the action
	float	 ActionTimer;		//amount of time that the action will take to be fully implemented  zero == instant
	bool	 ActionAlive;		//if true, an action is in progress
};


class CEnemy : public CEntity
{
public:
	CEnemy();
	virtual ~CEnemy();

	virtual void Render();
	virtual void Update();
	virtual void Load();
	virtual void TakeDamage( float damage = 1 );
	virtual void Kill();
	void FireBullet();

	void EquipPrimary( CWeapon* weapon );
	void UpdateCommands();

	void LookAtPlayer();

	void AttachItem( CSpecialItem* itemtoadd );
	void UpdateAttachedItems();
	void RemoveItem( CSpecialItem* itemtoremove );
	void RemoveAllItems();
	void DropItem();


	//perhaps a perform action at		counts down then does action when timer expires
	//and	    perform action until	counts down doing action until time expires
	//also a command class that does these, to enable multiple actions at once via an array or linked list calls
	//that can handle functions as parameters
	//the functions can set up for perform actions to chain events to make things slightly more emergent and simple
	void PerformAction( float& action, float change, float time );
	//bool UpdateAction();		//returns false if action wasn't updated, meaning it's finished

	void SetTimeAlive( float timealive )		{ TimeAlive = timealive; }
	void SetTimeUntilAlive( float time )		{ TimeUntilAlive = time; }
	//void UpdateTimeAlive()						{ TimeAlive += CEntity::pParent->DeltaTime; }
	//void UpdateTimeUntilAlive()					{ TimeUntilAlive -= pParent->DeltaTime; }
	void SetWaiting( bool waitingforspawn )		{ Waiting = waitingforspawn; }
	void SetParentWave( CWave* wave )			{ ParentWave = wave; }

	float GetTimeAlive()		{ return TimeAlive; }
	float GetTimeUntilAlive()	{ return TimeUntilAlive; }
	bool  GetWaiting()			{ return Waiting; }
	CWave* GetParentWave()		{ return ParentWave; }


	CWeapon* PrimaryWeapon;
	float	 TimeAlive;			//the time passed since this enemy has been alive
	float	 TimeUntilAlive;	//the time until this enemy will revive
	bool	 Waiting;			//waiting for spawn
	CWave*	 ParentWave;		//pointer to the wave that controls this enemy

	//CAction* Command;
	list< CAction* > Commands;
	list< CSpecialItem* > Items;
	int state;
	//bool inloop;
//	float*	 Action;			//reference to an action that can be changed. faceangle, speed, size, life, damage etc...
//	float	 ActionChange;		//the change to be performed to the action during ActionTime
//	float	 ActionTime;	    //total time for the action
//	float	 ActionTimer;		//amount of time that the action will take to be fully implemented  zero == instant
//	bool	 ActionAlive;			//if true, an action is in progress

								//use in darkbasic
	//float animedelay			//time before enemy becomes active
	//float animcount			//amount of times an animation is repeated
	//float animframe			//time that the enemy has been active

};


#endif